package lanQiaoBei.动态规划.背包问题;
import java.io.*;
import java.util.*;
public class P1{
       static BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
       final static int N=1010;
       static int v[]=new int[N],w[]=new int[N],pv[]=new int[N],pw[]=new int[N],n,vector,res;
       //暴力dfs
       static void dfs(int id){
              if(id>n){
                  if(pv[n]<=vector)
                  res=Math.max(pw[n],res);
                  return;
              }
              //累加前缀
              pv[id]=pv[id-1];
              pw[id]=pw[id-1];
              //不选择该编号物品
              dfs(id+1);
              //选择改编2号物品
              pv[id]+=v[id];
              pw[id]+=w[id];
              dfs(id+1);
       }
       public static void main(String[]ss)throws Exception{
              ss=br.readLine().split(" ");
              n=Integer.parseInt(ss[0]);vector=Integer.parseInt(ss[1]);
              for(int i=1;i<=n;i++){
                  ss=br.readLine().split(" ");
                  v[i]=Integer.parseInt(ss[0]);
                  w[i]=Integer.parseInt(ss[1]);
              }
              dfs(1);
              System.out.print(res);
       }
}